[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
setpalette() Change a Palette Color
#include <graphics.h>
void far setpalette(index,color);
int index;
int color;
setpalette() changes the palette color 'index' to the color specified
by 'color'. 'index' can range from 0 to the size of the palette minus
one (size - 1). (The size of the palette can be obtained using
getpalette()). 'color' can be one of the values or symbolic constants
defined in <graphics.h>:
COLOR TABLE
CGA EGA/VGA
Name Value Name Value
BLACK 0 EGA_BLACK 0
BLUE 1 EGA_BLUE 1
GREEN 2 EGA_GREEN 2
CYAN 3 EGA_CYAN 3
RED 4 EGA_RED 4
MAGENTA 5 EGA_MAGENTA 5
BROWN 6 EGA_BROWN 20
LIGHTGRAY 7 EGA_LIGHTGRAY 7
DARKGRAY 8 EGA_DARKGRAY 56
LIGHTBLUE 9 EGA_LIGHTBLUE 57
LIGHTGREEN 10 EGA_LIGHTGREEN 58
LIGHTCYAN 11 EGA_LIGHTCYAN 59
LIGHTRED 12 EGA_LIGHTRED 60
LIGHTMAGENTA 13 EGA_LIGHTMAGENTA 61
YELLOW 14 EGA_YELLOW 62
WHITE 15 EGA_WHITE 63
The values and symbolic constants used depend on the specific
graphics driver and graphics mode.
Returns: Nothing. If coded, graphresult() will return a -11
(graphics error) if the parameters passed to setpalette()
are invalid.
Notes: On a CGA, setpalette(index,color) should only be used if
'index' = 0. This is a way to set the background color to
'color'.
-------------------------------- Example ---------------------------------
The following statements change the color the string is printed in
from white to yellow.
#include <graphics.h>
int gdriver = DETECT;
int gmode;
main()
{
int whcolor;
struct palettetype palette;
initgraph(&gdriver,&gmode,"");
getpalette(&palette);
printf("Changes made to the palette are immediately seen.\n");
delay(1000);
setpalette(7,62);
delay(2000);
closegraph();
}
See Also:
getbkcolor()
getcolor()
getpalette()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson